__all__ = [
    "grpc_all_result_point"
]

from apps.crawler_platform.core_callback.grpc_callback.wanfang import wanfang_search_type_result_callback, \
    wanfang_search_list_result_callback, wanfang_article_grpc_result_callback


def grpc_all_result_point(self):
    """
    一个锚点函数，所有的result过该函数做判断
    :return:
    """
    bytes = self.html_bytes
    task_name = self.other_dicts["task_name"]
    task_tag = self.other_dicts["task_tag"]
    keys = self.other_dicts["keys"]
    if task_name == "wanfangjournal" and task_tag == "wanfangarticle" and keys in ("1_3", "1_1", "1_2"):
        # 万方期刊的结果采用相同的结构返回
        str_dic = wanfang_article_grpc_result_callback(bytes)
        return str_dic
    if "_search_list" in task_tag or "_typelist" in task_tag or "_yearlist" in task_tag:
        str_dic = wanfang_search_type_result_callback(bytes)
        return str_dic
    if "_search_sublist" in task_tag:
        str_dic = wanfang_search_list_result_callback(bytes)
        return str_dic
    if "_search_article"  in task_tag:
        str_dic = wanfang_article_grpc_result_callback(bytes)
        return str_dic
